<template>
      <div class="block">
        <span class="demonstration">默认 click 触发子菜单</span>
        <avue-form v-model="formData" :option="option" @submit="submit"></avue-form>

        <avue-crud :option="tableOption" v-model="tableForm" :search.sync="search" :data="tableData" @row-save="rowSave" @row-update="rowUpdate">
        </avue-crud>

        <el-select
            v-model="valueCustom"
            filterable
            allow-create
            default-first-option
            placeholder="请选择文章标签">
          <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
          </el-option>
        </el-select>
        <el-button @click="showValueCustom">显示</el-button>
    </div>
</template>

<script>
   export default {
     name: "index",
     components: {

     },

     created() {

     },
     data(){
       const dicData=[{
         value: '指南',
         label: '指南',
         children: [{
           value: '设计原则',
           label: '设计原则',
           children: [{
             value: '一致',
             label: '一致'
           }, {
             value: '反馈',
             label: '反馈'
           }]
         }]
       },{
         value: '指南2',
         label: '指南2',
       }]
       return {
         formData:{},
         option: {
           column: [{
             label: '级联',
             prop: 'cascader',
             type: "cascader",
             dicData: dicData
           }]
         },
         search:{},
         tableForm:{},
         tableData:[{cascader:['指南','设计原则','一致']}],
         tableOption:{

           column: [{
             label: '级联',
             prop: 'cascader',
             type: "cascader",
             dicData: dicData
           }]
         },
         options: [{
           value: 'HTML',
           label: 'HTML'
         }, {
           value: 'CSS',
           label: 'CSS'
         }, {
           value: 'JavaScript',
           label: 'JavaScript'
         }],
         valueCustom: []
       }
     },
     methods:{
       submit(value) {
         console.log(this.formData);
       },
       rowSave(row, done, loading) {
         console.log("row:", row)
         this.tableData.push(row)
         done()
       },
       rowUpdate(row, index, done, loading) {
         this.tableData.splice(index, 1, row)
         done()
       },
       showValueCustom(){
         console.log(this.valueCustom)
         let str = '00009-开始截取-测试结束'
         let  index = str.indexOf('-')
         let a = str.substring(0,index)  //codeName.split('-')[0]
         let b = str.substring(index+1,str.length)//codeName.split('-')[1]

         console.log("---a:",a,'----b:',b)
       }
     }
   }
</script>

<style scoped>

</style>